package com.xinggq.pay.api.dto;

import com.xinggq.pay.api.enums.YsePayWayEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import lombok.Data;

/**
 * 银盛统一支付接口的参数封装类
 * @Description
 * @Author xinggq
 * @Date 2025/9/9
 */
@Data
@Schema(description = "银盛统一支付请求参数")
public class YseCommonPayReqDTO {

  /**
   * 商户侧订单号
   */
  @Schema(description = "商户侧订单号", example = "PAY202501200001", requiredMode = Schema.RequiredMode.REQUIRED)
  @NotNull(message = "商户侧订单号不能为空")
  private String merchantOutTradeNo;

  /**
   * 支付渠道订单号
   */
  @Schema(description = "支付平台订单号", example = "P202501200001")
  private String tradeNo;

  /**
   * 支付渠道订单号
   */
  @Schema(description = "支付渠道订单号", example = "4200001234567890")
  private String channelOutTradeNo;

  /**
   * 银盛支付方式
   */
  @Schema(description = "银盛支付方式", example = "WECHAT_JSAPI", requiredMode = Schema.RequiredMode.REQUIRED)
  @NotNull(message = "银盛支付方式不能为空")
  private YsePayWayEnum ysePayWay;

  /**
   * 该笔订单的资金总额，单位为RMB-Yuan。取值范围为[0.01，100000000.00]，精确到小数点后两位。Number(10,2)指10位长度，2位精度。100
   */
  @Schema(
      description = "订单金额，单位：元",
      example = "99.99",
      minimum = "0.01",
      maximum = "100000000.00",
      requiredMode = Schema.RequiredMode.REQUIRED
  )
  @NotNull(message = "订单金额不能为空")
  private BigDecimal totalAmount;

  /**
   * 订单备注
   */
  @Schema(description = "订单备注", example = "商品购买")
  private String subject;

  /**
   * 微信支付专用参数
   */
  @Schema(description = "微信支付专用参数")
  private WechatPayParams wechatParams;

  /**
   * 网银支付专用参数
   */
  @Schema(description = "网银支付专用参数")
  private BankPayParams bankParams;

  /**
   * 网银支付专用参数
   */
  @Data
  @Schema(description = "网银支付参数")
  public static class BankPayParams {
    /**
     * 银盛支付处理完请求后，当前页面自动跳转到商户网站里指定页面的http路径。
     */
    @Schema(description = "支付完成后的跳转地址", example = "https://www.example.com/return")
    private String returnUrl;
  }

  /**
   * 微信支付专用参数
   */
  @Data
  @Schema(description = "微信支付参数")
  public static class WechatPayParams {
    /**
     * 微信公众号或小程序的appid
     */
    @Schema(description = "微信公众号或小程序的appid", example = "wx1234567890")
    private String wxOpenAppid;

    /**
     * 用户在商户appid下的授权唯一标识
     */
    @Schema(description = "用户的微信openid", example = "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o")
    private String subOpenid;
  }
}
